package xyz.esion.povertyalleviation.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.esion.povertyalleviation.entry.R;
import xyz.esion.povertyalleviation.service.TCountyService;
import xyz.esion.povertyalleviation.service.TIndustryTypeService;
import xyz.esion.povertyalleviation.service.TVillageService;

/**
 * @author Esion
 * @since 2021/5/5
 */
@RestController
@RequestMapping("api/data")
public class DataController {

    private final TIndustryTypeService industryTypeService;
    private final TCountyService countyService;
    private final TVillageService villageService;

    @Autowired
    public DataController(TIndustryTypeService industryTypeService, TCountyService countyService, TVillageService villageService) {
        this.industryTypeService = industryTypeService;
        this.countyService = countyService;
        this.villageService = villageService;
    }

    @GetMapping("type")
    public R type(){
        return R.success().data("items", industryTypeService.list());
    }

    @GetMapping("county")
    public R county(){
        return R.success().data("items", countyService.list());
    }

    @GetMapping("village")
    public R village(){
        return R.success().data("items", villageService.list());
    }

}
